package com.rerun.service.impl;


import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rerun.common.util.PageHelper;
import com.rerun.entity.YoyoPark;
import com.rerun.entity.vo.ParkListShowVo;
import com.rerun.entity.vo.WatchedMeParkVo;
import com.rerun.mapper.YoyoParkMapper;
import com.rerun.service.IYoyoParkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * The type Yoyo park service.
 *
 * @author dax.
 * @version v1.0
 * @since 2017 /9/29 19:44
 */
@Service
public class YoyoParkServiceImpl extends ServiceImpl<YoyoParkMapper, YoyoPark> implements IYoyoParkService {
    /**
     * @param map
     * @param pageNumber
     * @param pageSize
     * @return ParkListShowVo
     * 展示园所列表信息
     */
    @Resource
    private YoyoParkMapper yoyoParkMapper;

    @Override
    public List<ParkListShowVo> showParkList(Map<String, Object> map,
                                             Integer pageNumber, Integer pageSize) {

        return yoyoParkMapper.showParkList(map, pageNumber, pageSize);
    }

    @Override
    public List<WatchedMeParkVo> selectListWatchedMe(String memberId) {
        return yoyoParkMapper.selectListWatchedMe(memberId);
    }

    @Override
    public List<WatchedMeParkVo> selectListCollectionMe(String memberId) {
        return yoyoParkMapper.selectListCollectionMe(memberId);
    }

    @Override
    public List<YoyoPark> selectPageForBlackList(List<String> ids) {
        return yoyoParkMapper.selectPageForBlackList(ids);
    }

    @Override
    public Page<YoyoPark> selectListByParams(Page<YoyoPark> parkPage, String parkName) {
        int cur = PageHelper.curPageStart(yoyoParkMapper.selectListByParamsCount(parkName), parkPage);
        List<YoyoPark> yoyoParks = yoyoParkMapper.selectListByParams(cur, parkPage.getSize(), parkName);
        parkPage.setRecords(yoyoParks);
        return parkPage;
    }

    @Override
    public int selectListByParamsCount(String parkName) {
        return yoyoParkMapper.selectListByParamsCount(parkName);
    }


}
